﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Services;

namespace MainGame.Menu
{

  public interface IMainMenu
  {

    event MenuEvent OnSettingsClicked;
    event MenuEvent OnHelpClicked;
    event MenuEvent OnCreditsClicked;

  }


  public class MainMenu : BaseMenu, IMainMenu
  {

    Button settingsBtn, creditsBtn, helpBtn;
   

    public MainMenu(Game game, MenuDepths depth)
      : base(game, depth)
    {
      background = game.Content.Load<Texture2D>(@"Images//Menu//startMenu");
      bounds = new Rectangle(300, 100, 200, 300);
      game.Services.AddService(typeof(IMainMenu), this);
    }

    protected override void Dispose(bool disposing)
    {
      Game.Services.RemoveService(typeof(IMainMenu));
      base.Dispose(disposing);
    }


    public override void Initialize()
    {
      // Load all buttons
      settingsBtn = new Button(Game, @"Images//Menu//button_play", new Rectangle(330, 150, 140, 25), "large_font" , "Settings");
      AddButton(settingsBtn, () => {
        if (OnSettingsClicked != null)
            OnSettingsClicked();
         });
      creditsBtn = new Button(Game, @"Images//Menu//button_play", new Rectangle(330, 200, 140, 25), "large_font", "Credits");
      AddButton(creditsBtn, () =>
      {
        if (OnCreditsClicked != null)
          OnCreditsClicked();
      });
      helpBtn = new Button(Game, @"Images//Menu//button_play", new Rectangle(330, 250, 140, 25), "large_font", "Help");
      AddButton(helpBtn, () =>
      {
        if (OnHelpClicked != null)
          OnHelpClicked();
      });
      
      base.Initialize();
    }

    public override void Update(GameTime gameTime)
    {
      
      base.Update(gameTime);
    }

    public event MenuEvent OnSettingsClicked;
    public event MenuEvent OnHelpClicked;
    public event MenuEvent OnCreditsClicked;

  }
}
